<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@include file="/includes.jsp"%>

<h1 class="layout">
    <logic:empty name="roleValue" property="roleId">
        Create
    </logic:empty>
    <logic:notEmpty name="roleValue" property="roleId">
        Edit
    </logic:notEmpty>
    Role
</h1>

<html:form action="role.do?method=edit" method="post">
    <table class="layout" style="background-image: url(<html:rewrite page='/icons/role-32x32.png'/>);">
        <tr>
            <th class="layout">Name:</th>
            <td class="layout"><html:text name="roleActionForm" property="name" size="80"/></td>
        </tr>
        <tr>
            <th class="layout">Description:</th>
            <td class="layout"><html:textarea name="roleActionForm" property="description" cols="60" rows="10"/></td>
        </tr>
        <tr>
            <th class="layout">Recursive:</th>
            <td class="layout"><html:checkbox name="roleActionForm" property="isRecursive"/> Should the role be assigned recursively?</td>
        </tr>
        <tr>
            <th class="layout">Permissions:</th>
            <td class="layout">
                <table class="styled" cellspacing="0">
                    <tr>
                        <th class="styled">Permission</th>
                        <th class="styled">Enabled</th>
                    </tr>
                    <logic:iterate name="roleActionForm" property="permissions" id="key">
                        <html:hidden name="roleActionForm" property='<%= "permissionId(" + key + ")" %>'/>
                        <tr>
                            <td class="styled"><beans:write name="key"/></td>
                            <td class="styled" style="text-align: center;">
                                <html:checkbox name="roleActionForm" property='<%= "permissionEnabled(" + key + ")" %>'/>
                            </td>
                        </tr>
                    </logic:iterate>
                </table>
            </td>
        </tr>
    </table>
    <div class="buttons">
        <html:submit property="btnSubmit" value="OK"/>
        <html:cancel property="btnSubmit" value="Cancel"/>
    </div>
</html:form>
